class FenceGateRenderer : public IBlockRenderer
{
public:
	ITexture *Texture;

	FenceGateRenderer(ITexture *texture) :
		Texture(texture)
	{
	}

	int GetTypeData(const int &data) { return data; }

	void Render(Schematic *schematic, RendererBase *renderer, const Block &block, const Point3i &position)
	{
		byte dir = (byte)(block.Data & ~0x04);
		bool opened = (block.Data & 0x04) != 0;

		renderer->Translate(8, 8, 8);
		renderer->Rotate(dir * -90, 0, 1, 0);
		renderer->Translate(-8, -8, -8);

		renderer->Draw(Box(Texture, Point3i(2, 11, 2), Point3i(0, 0, 7)).SetCoordsFromBounds(Point2i(4 * 16, 0)));
		renderer->Draw(Box(Texture, Point3i(2, 11, 2), Point3i(14, 0, 7)).SetCoordsFromBounds(Point2i(4 * 16, 0)));
		
		if (opened)
		{
			renderer->PushState();
			renderer->Translate(1, 0, 8);
			renderer->Rotate(-90, 0, 1, 0);
			renderer->Translate(-1, -0, -8);
		}

		renderer->Draw(Box(Texture, Point3i(4, 3, 2), Point3i(2, 1, 7)).SetCoordsFromBounds(Point2i(4 * 16, 0)));
		renderer->Draw(Box(Texture, Point3i(4, 3, 2), Point3i(2, 7, 7)).SetCoordsFromBounds(Point2i(4 * 16, 0)));
		renderer->Draw(Box(Texture, Point3i(2, 9, 2), Point3i(6, 1, 7)).SetCoordsFromBounds(Point2i(4 * 16, 0)));

		if (opened)
		{
			renderer->PopState();
			renderer->PushState();

			renderer->Translate(15, 0, 8);
			renderer->Rotate(90, 0, 1, 0);
			renderer->Translate(-15, -0, -8);
		}

		renderer->Draw(Box(Texture, Point3i(2, 9, 2), Point3i(8, 1, 7)).SetCoordsFromBounds(Point2i(4 * 16, 0)));
		renderer->Draw(Box(Texture, Point3i(4, 3, 2), Point3i(10, 1, 7)).SetCoordsFromBounds(Point2i(4 * 16, 0)));
		renderer->Draw(Box(Texture, Point3i(4, 3, 2), Point3i(10, 7, 7)).SetCoordsFromBounds(Point2i(4 * 16, 0)));
		
		if (opened)
			renderer->PopState();
	}
};